<!--********************************************************************
* Copyright© 2000 - 2025 SuperMap Software Co.Ltd. All rights reserved.
*********************************************************************-->
<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title data-i18n="resources.title_l_echartsEarthquake"></title>
    <script type="text/javascript" include="papaparse,jquery" src="../js/include-web.js"></script>
</head>

<body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
    <div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
    <script type="text/javascript" src="../../dist/leaflet/include-leaflet.js"></script>
    <script type="text/javascript">
        var host = window.isLocal ? window.server : "https://iserver.supermap.io";
        var url = host + "/iserver/services/map-china/rest/maps/China";

        var map, heatMapLayer;

        map = L.map('map', {
            center: [32.67, 109.06],
            zoom: 5
        });
        new L.supermap.TiledMapLayer(url).addTo(map);

        addHeatMapLayer();

        function addHeatMapLayer() {
            heatMapLayer = new L.supermap.HeatMapLayer("heatMap", {
                id: "heatmap",
                map: map,
                radius: 10,
                featureWeight: "value"
            });

            $.get("../data/chinaEarthquake.csv", function (response) {
                var dataObj = Papa.parse(response, {
                    skipEmptyLines: true,
                    header: true
                });

                var data = dataObj.data;

                var geojson = {
                    "type": "FeatureCollection",
                    "features": []
                };


                for (var i = 0; i < data.length; i++) {
                    var item = data[i];
                    var date = new Date(item.date);
                    var year = date.getFullYear();

                    //2w+地震数据
                    if (year > 2000 && year < 2015) {
                        var feature = {
                            "type": "feature",
                            "geometry": {
                                "type": "Point",
                                "coordinates": []
                            },
                            "properties": {
                                "value": parseFloat(item.level)
                            }
                        };
                        feature.geometry.coordinates = [parseFloat(item.X), parseFloat(item.Y)];

                        geojson.features.push(feature);
                    }
                }
                heatMapLayer.addFeatures(geojson);
                heatMapLayer.addTo(map);
            });
        }
    </script>
</body>

</html>